//
//  CommitStarsView.m
//  PeopleStreet
//
//  Created by 辰领科技 on 16/1/18.
//  Copyright © 2016年 yuf. All rights reserved.
//

#import "CommitStarsView.h"

@implementation CommitStarsView

- (instancetype)initWithFrame:(CGRect)frame Stars:(CGFloat)stars{
    self = [super initWithFrame:frame];
    if (self) {
        
        CGFloat left =stars - stars/1;
        if (left<0.5) {
            stars = stars;
        }else if (left>=0.5){
            stars = stars+0.5;
        }
        
        
        int Ynumber = stars/1;
        int Cnumber = 0;
        int YCnumber = 0;
        int number = stars/0.5;
        if (number%2==0) {
            YCnumber = 0;
            Cnumber = 5-Ynumber;
        }else{
            YCnumber = 1;
            Cnumber = 4-Ynumber;
        }
        
        for (int i = 0; i<Ynumber; i++) {
            UIImageView * star = [[UIImageView alloc]initWithFrame:flexibleFrame(CGRectMake(16*i, 0, 15, 15), NO)];
            star.image = [UIImage imageNamed:@"comment5"];
            [self addSubview:star];
            
        }
        
        if (YCnumber==0) {
            for (int i = 0;i<Cnumber ; i++) {
                UIImageView * star = [[UIImageView alloc]initWithFrame:flexibleFrame(CGRectMake((Ynumber+i)*16, 0, 15, 15), NO)];
                star.image = [UIImage imageNamed:@"comment6"];
                [self addSubview:star];
            }
            
        }else{
            UIImageView * star = [[UIImageView alloc]initWithFrame:flexibleFrame(CGRectMake((Ynumber)*16, 0, 15, 15), NO)];
            star.image = [UIImage imageNamed:@"comment7"];
            [self addSubview:star];
            
            for (int i = 0;i<Cnumber ; i++) {
                UIImageView * star = [[UIImageView alloc]initWithFrame:flexibleFrame(CGRectMake((Ynumber+i+1)*16, 0, 15, 15), NO)];
                star.image = [UIImage imageNamed:@"comment6"];
                [self addSubview:star];
            }
        
        }
        
    }
    return self;

}

- (instancetype)initWithFrame:(CGRect)frame SmallStars:(CGFloat)stars{
    self = [super initWithFrame:frame];
    if (self) {
        int Ynumber = stars/1;
        int Cnumber = 0;
        int YCnumber = 0;
        int number = stars/0.5;
        if (number%2==0) {
            YCnumber = 0;
            Cnumber = 5-Ynumber;
        }else{
            YCnumber = 1;
            Cnumber = 4-Ynumber;
        }
        
        for (int i = 0; i<Ynumber; i++) {
            UIImageView * star = [[UIImageView alloc]initWithFrame:flexibleFrame(CGRectMake(11*i, 0, 10, 10), NO)];
            star.image = [UIImage imageNamed:@"shop15"];
            [self addSubview:star];
            
        }
        
        if (YCnumber==0) {
            for (int i = 0;i<Cnumber ; i++) {
                UIImageView * star = [[UIImageView alloc]initWithFrame:flexibleFrame(CGRectMake((Ynumber+i)*11, 0, 10, 10), NO)];
                star.image = [UIImage imageNamed:@"shop17"];
                [self addSubview:star];
            }
            
        }else{
            UIImageView * star = [[UIImageView alloc]initWithFrame:flexibleFrame(CGRectMake((Ynumber)*11, 0, 10, 10), NO)];
            star.image = [UIImage imageNamed:@"shop16"];
            [self addSubview:star];
            
            for (int i = 0;i<Cnumber ; i++) {
                UIImageView * star = [[UIImageView alloc]initWithFrame:flexibleFrame(CGRectMake((Ynumber+i+1)*11, 0, 10, 10), NO)];
                star.image = [UIImage imageNamed:@"shop17"];
                [self addSubview:star];
            }
            
        }
        
    }
    return self;
    
}


@end
